package cn.demo.um.service.impl;

import java.util.List;
import com.mybatisflex.core.paginate.Page;
import cn.demo.common.core.page.PageQuery;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.demo.um.mapper.UmContentFocusMapper;
import cn.demo.um.domain.UmContentFocus;
import cn.demo.um.service.IUmContentFocusService;

/**
 * 用户文章点赞Service业务层处理
 *
 * @author xtjun
 * @date 2024-06-06
 */
@Service
public class UmContentFocusServiceImpl extends ServiceImpl<UmContentFocusMapper, UmContentFocus> implements IUmContentFocusService {
    @Resource
    private UmContentFocusMapper umContentFocusMapper;
    /**
     * 查询用户文章点赞
     *
     * @param userId 用户文章点赞主键
     * @return 用户文章点赞
     */
    @Override
    public UmContentFocus selectUmContentFocusByUserId(String userId) {
        return umContentFocusMapper.selectOneById(userId);
    }

    /**
     * 查询用户文章点赞列表
     *
     * @param umContentFocus 用户文章点赞
     * @return 用户文章点赞
     */
    @Override
    public Page<UmContentFocus> selectUmContentFocusPage(UmContentFocus umContentFocus, PageQuery pageQuery) {
        return umContentFocusMapper.paginate(pageQuery.build(), QueryWrapper.create(umContentFocus,UmContentFocus.operators));
    }
    @Override
    public List<UmContentFocus> selectUmContentFocusList(UmContentFocus umContentFocus) {
        return umContentFocusMapper.selectListByQuery(QueryWrapper.create(umContentFocus,UmContentFocus.operators));
    }

    /**
     * 新增用户文章点赞
     *
     * @param umContentFocus 用户文章点赞
     * @return 结果
     */
    @Override
    public int insertUmContentFocus(UmContentFocus umContentFocus) {
        return umContentFocusMapper.insert(umContentFocus);
    }

    /**
     * 修改用户文章点赞
     *
     * @param umContentFocus 用户文章点赞
     * @return 结果
     */
    @Override
    public int updateUmContentFocus(UmContentFocus umContentFocus) {
        return umContentFocusMapper.update(umContentFocus);
    }

    /**
     * 批量删除用户文章点赞
     *
     * @param userIds 需要删除的用户文章点赞主键
     * @return 结果
     */
    @Override
    public int deleteUmContentFocusByUserIds(List<String> userIds) {
        return umContentFocusMapper.deleteBatchByIds(userIds);
    }

    /**
     * 删除用户文章点赞信息
     *
     * @param userId 用户文章点赞主键
     * @return 结果
     */
    @Override
    public int deleteUmContentFocusByUserId(String userId) {
        return umContentFocusMapper.deleteById(userId);
    }
}
